package org.example.struct.array2;

/**
 * @author liyishan
 * @date 2024/6/14 10:08
 * @apiNote
 */

public class Test02786MaxScore {

    public long maxScore(int[] nums, int x) {
        long res = nums[0];
        long[] dp = {Integer.MIN_VALUE, Integer.MIN_VALUE};
        dp[nums[0] %2] = nums[0];
        for(int i = 1; i<nums.length;i++){
            int temp = nums[i] % 2;
            long cur = Math.max(dp[temp]+nums[i],dp[1-temp]-x+nums[i]);
            res = Math.max(res,cur);
            dp[temp] = Math.max(dp[temp],cur);
        }
        return res;
    }
}
